new Vue({
  el: "#app",
  data() {
    return {
      form: {
        App_ID: "",
        Client_ID: "",
        Client_Secret: "",
        Robot_Code: "",
        Application_Name: "",
        Enterprise_Info_SerialNumber: $.cookie("enterprise"),
      },
      rules: {
        App_ID: [{ required: true, message: "请输入App_ID", trigger: "blur" }],
        Client_ID: [
          { required: true, message: "请输入功能ID", trigger: "blur" },
        ],
        Client_Secret: [
          { required: true, message: "请输入密钥", trigger: "blur" },
        ],
        Application_Name: [
          { required: true, message: "请输入功能名称", trigger: "blur" },
        ],
      },
      loading: false,
    };
  },
  mounted() {},
  methods: {
    submitForm(formName) {
      const that = this;
      this.$refs[formName].validate((valid) => {
        if (valid) {
          that.loading = true;
          $.ajax({
            headers: requestHeaders(),
            url: `${BASE_URL2}/generalBusiness/generalSave`,
            type: "POST",
            data: {
              Data: JSON.stringify({
                Add: { dingtalk_application: [that.form] },
              }),
            },
            success: function (res) {
              if (res.Status === "success") {
                that.$message.success("提交成功");
                window.history.go(-1);
              } else {
                that.$message.error("提交失败，请稍后再试");
              }
            },
            // complete: function (XMLHttpRequest) {
            //     that.loading = false
            //     requestPretreatment(XMLHttpRequest);
            // },
            dataType: "json",
          });
        } else {
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    },
  },
});
